home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Grafik / Misc / ImageEnginer / ARexx / Batch / Resize.ieb < prev    next >
Encoding:
Text File  |  1997-02-02  |  3.1 KB  |  126 lines

  1. /*
  2. ** $VER: Resize.ieb 1.12, IE Arexx script
  3. ** Image Engineer Batch Processing script
  4. ** Copyright © by Patrik M Nydensten
  5. ** 2/2 1997 Stockholm/Sweden
  6. **
  7. ** Resize image to new size.
  8. */
  9.  
  10. options results
  11. signal on error
  12.  
  13. parse arg input command
  14. input = upper(strip(input))
  15. address 'IMAGEENGINEER'
  16.  
  17. select  /* Required batch script commands */
  18.   when input = 'INFO' then    return get_info()
  19.   when input = 'CONFIG' then  return get_config(command)
  20.   when input = 'PROCESS' then return process_image(command)
  21.   otherwise do
  22.     'REQUEST' '"Failure in call to batch script!"' '" Quit "'
  23.     return '<ERROR>'
  24.   end
  25. end
  26.  
  27. exit 0
  28.  
  29. /* Required "Get_info" procedure  ------------------------------------ */
  30. /* S = SECONDARY, A = ALPHA, 1 = Single file, 2 = Multiple files       */
  31.  
  32. get_info:
  33.   back = 'OK'
  34. return back
  35.  
  36. /* Required "Get_config" procedure  ---------------------------------- */
  37.  
  38. get_config:
  39.   parse arg '"'command'"'
  40.  
  41.   NewWidth=320 ; NewHeight=256
  42.  
  43.   if command ~= '' then parse var command NewWidth NewHeight '#'Tile '#'Center .
  44.  
  45.   'IE_TO_FRONT'
  46.  
  47.   form = 'FORM "Resize" " OK | Cancel "',
  48.   ' INTEGER,"New image width",2,4096,'NewWidth',SLIDER',
  49.   ' INTEGER,"New image height",2,4096,'NewHeight',SLIDER'
  50.  
  51.   if command = '' then do
  52.     form = form||' CHECKBOX,"Tile (repeat) image?",0',
  53.     ' CHECKBOX,"Center image?",1'
  54.  
  55.     form
  56.     parse var result ok NewWidth NewHeight Tile Center .
  57.     if ok = 0 then return '<ERROR>'
  58.   end
  59.   else do
  60.     form
  61.     parse var result ok NewWidth NewHeight .
  62.     if ok = 0 then return '<ERROR>'
  63.  
  64.     Tile = 'none'
  65.     Center = 'none'
  66.   end
  67.  
  68.   back = NewWidth NewHeight '#'Tile '#'Center
  69. return back
  70.  
  71. /* Required "Process_image" procedure  ------------------------------- */
  72.  
  73. process_image:
  74.   parse arg '"'src_image'"' '"'dst_image'"' '"'options'"'
  75.   parse var options NewWidth NewHeight '#'Tile '#'Center .
  76.  
  77.   'OPEN' '"'src_image'"' '24'
  78.   if (RC ~= 0) then do
  79.     'IE_TO_FRONT'
  80.     'REQUEST' '"Failed to load image:' d2c(10)||src_image'"' '" OK "'
  81.     return '<ERROR>'
  82.   end
  83.   else LoadImage = result
  84.  
  85.   if Tile = 1 then Tile = 'TILE'
  86.   else Tile = ''
  87.  
  88.   if Center = 1 then Center = 'CENTER'
  89.   else Center = ''
  90.  
  91.   'RESIZE' LoadImage NewWidth NewHeight Center Tile
  92.   OutputImage = result
  93.   'CLOSE' LoadImage
  94.  
  95.   'SAVE_DATA' OutputImage '"'dst_image'"' '"ILBM CmpByteRun1"'
  96.   if (RC ~= 0) then do
  97.     'IE_TO_FRONT'
  98.     'REQUEST' '"Failed to save image:' d2c(10)||dst_image'"' '" OK "'
  99.     return '<ERROR>'
  100.   end
  101.   'CLOSE' OutputImage
  102.  
  103.   back = 'OK'
  104. return back
  105.  
  106. /* Internal procedures  ---------------------------------------------- */
  107.  
  108. /*******************************************************************/
  109. /* This is where control goes when an error code is returned by IE */
  110. /* It puts up a message saying what happened and on which line     */
  111. /*******************************************************************/
  112.  
  113. error:
  114. if RC=5 then do
  115.     IE_TO_FRONT
  116.     LAST_ERROR
  117.     'REQUEST "'||RESULT||'"'
  118. end
  119. else do
  120.     IE_TO_FRONT
  121.     LAST_ERROR
  122.     'REQUEST "Error detected!!!'||D2C(10)||'Image Engineer error message is as follows'||D2C(10)||result||D2C(10)||'Script failed on line '||SIGL||'"' 'Doh!'
  123. end
  124.  
  125. return '<ERROR>'
  126.